/**
 * 
 */
package com.orisper.omp.modules.product;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.orisper.dao.Bm_product_faqDao;
import com.orisper.dao.Bm_product_faqPO;
import com.orisper.dao.Bm_product_imgDao;
import com.orisper.dao.Bm_product_imgPO;
import com.orisper.dao.Bm_product_paramsDao;
import com.orisper.dao.Bm_product_paramsPO;

import aos.framework.core.id.AOSId;
import aos.framework.core.typewrap.Dto;
import aos.framework.core.utils.AOSJson;
import aos.framework.web.router.HttpModel;
import aos.system.common.service.AOSBaseService;

/**
 * @author Administrator
 *
 */
@Service
public class ProductDetailService extends AOSBaseService{
	
	@Autowired
	Bm_product_paramsDao bm_product_paramsDao;
	
	@Autowired
	Bm_product_faqDao bm_product_faqDao;
	
	@Autowired
	Bm_product_imgDao bm_product_imgDao;
	
	/**
	 * 产品页面初始化
	 * 
	 * @param httpModel
	 * @return
	 */
	public void init(HttpModel httpModel) {
		httpModel.setAttribute("juid", httpModel.getInDto().getString("juid"));
		httpModel.setViewPath("project/orisper/productDetailManage.jsp");
	}
	
	
	/**
	 * 查询参数
	 * 
	 * @param httpModel
	 * @return
	 */
	public void queryParamsList(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		List<Dto> list = sqlDao.list("Product.queryParamsListPage",inDto);
		httpModel.setOutMsg(AOSJson.toGridJson(list, inDto.getPageTotal()));
	}
	
	
	/**
	 * 添加参数
	 * 
	 * @param httpModel
	 * @return
	 */
	public void addParam(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_paramsPO bm_product_paramsPO = new Bm_product_paramsPO();
		bm_product_paramsPO.copyProperties(inDto);
		bm_product_paramsPO.setId(AOSId.uuid());
		bm_product_paramsPO.setCreate_date(new Date());
		bm_product_paramsDao.insert(bm_product_paramsPO);
		httpModel.setOutMsg("添加成功");
	}
	
	
	/**
	 * 更新faq
	 * 
	 * @param httpModel
	 * @return
	 */
	public void updateParam(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_paramsPO bm_product_paramsPO = new Bm_product_paramsPO();
		bm_product_paramsPO.copyProperties(inDto);
		bm_product_paramsPO.setModify_date(new Date());
		bm_product_paramsDao.updateByKey(bm_product_paramsPO);
		httpModel.setOutMsg("修改成功");
	}
	
	
	/**
	 * 查询参数
	 * 
	 * @param httpModel
	 * @return
	 */
	public void getParam(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_paramsPO bm_product_paramsPO=bm_product_paramsDao.selectByKey(inDto.getString("id"));
		httpModel.setOutMsg(AOSJson.toJson(bm_product_paramsPO));
	}
	
	/**
	 * 删除参数
	 * 
	 * @param httpModel
	 * @return
	 */
	public void deleteParam(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Integer res=bm_product_paramsDao.deleteByKey(inDto.getString("id"));
		String result=res>0?"删除成功":"删除失败";
		httpModel.setOutMsg(result);
	}
	
	
	
	/**
	 * 查询faq
	 * 
	 * @param httpModel
	 * @return
	 */
	public void queryFaqList(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		List<Dto> list = sqlDao.list("Product.queryFaqListPage",inDto);
		httpModel.setOutMsg(AOSJson.toGridJson(list, inDto.getPageTotal()));
	}
	
	/**
	 * 添加faq
	 * 
	 * @param httpModel
	 * @return
	 */
	public void addFaq(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_faqPO bm_product_faqPO = new Bm_product_faqPO();
		bm_product_faqPO.copyProperties(inDto);
		bm_product_faqPO.setId(AOSId.uuid());
		bm_product_faqPO.setCreate_date(new Date());
		bm_product_faqDao.insert(bm_product_faqPO);
		httpModel.setOutMsg("添加成功");
	}
	
	
	
	
	/**
	 * 查询faq
	 * 
	 * @param httpModel
	 * @return
	 */
	public void getFaq(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_faqPO bm_product_faqPO = bm_product_faqDao.selectByKey(inDto.getString("id"));
		httpModel.setOutMsg(AOSJson.toJson(bm_product_faqPO));
	}
	
	/**
	 * 更新faq
	 * 
	 * @param httpModel
	 * @return
	 */
	public void updateFaq(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_faqPO bm_product_faqPO = new Bm_product_faqPO();
		bm_product_faqPO.copyProperties(inDto);
		bm_product_faqPO.setModify_date(new Date());
		bm_product_faqDao.updateByKey(bm_product_faqPO);
		httpModel.setOutMsg("修改成功");
	}
	
	/**
	 * 删除faq
	 * 
	 * @param httpModel
	 * @return
	 */
	public void deleteFaq(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Integer res=bm_product_faqDao.deleteByKey(inDto.getString("id"));
		String result=res>0?"删除成功":"删除失败";
		httpModel.setOutMsg(result);
	}
		
	
	
	/**
	 * 产品详情图列表
	 * 
	 * @param httpModel
	 * @return
	 */
	public void queryImgList(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		List<Dto> list = sqlDao.list("Product.queryImgListPage",inDto);
		httpModel.setOutMsg(AOSJson.toGridJson(list, inDto.getPageTotal()));
	}
	
	
	
    /**
     * 添加产品详情图
     * @param httpModel
     */
	public void addImg(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_imgPO bm_product_imgPO = new Bm_product_imgPO();
		bm_product_imgPO.copyProperties(inDto);
		bm_product_imgPO.setId(AOSId.uuid());
		bm_product_imgPO.setCreate_date(new Date());
		bm_product_imgDao.insert(bm_product_imgPO);
	    httpModel.setOutMsg("添加成功");
	}
	
	/**
	 * 查询产品详情图
	 * 
	 * @param httpModel
	 * @return
	 */
	public void getImg(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_imgPO bm_product_imgPO = bm_product_imgDao.selectByKey(inDto.getString("id"));
		httpModel.setOutMsg(AOSJson.toJson(bm_product_imgPO));
	}
	
	/**
	 * 更新产品详情图
	 * 
	 * @param httpModel
	 * @return
	 */
	public void updateImg(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_product_imgPO bm_product_imgPO = new Bm_product_imgPO();
		bm_product_imgPO.copyProperties(inDto);
		bm_product_imgPO.setModify_date(new Date());
		bm_product_imgDao.updateByKey(bm_product_imgPO);
		httpModel.setOutMsg("修改成功");
	}
	
	/**
	 * 删除产品详情图	
	 * @param httpModel
	 */
	public void deleteImg(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Integer res=bm_product_imgDao.deleteByKey(inDto.getString("id"));
		String result=res>0?"删除成功":"删除失败";
		httpModel.setOutMsg(result);
	}
			
	
}
